package org.zoomdev.zoom.protobuf.modules;

import io.protostuff.ByteArrayInput;
import io.protostuff.ProtostuffOutput;
import io.protostuff.Schema;

import java.io.IOException;

final class PojoSchema implements ISchema {

    private final Schema schema;

    public PojoSchema(Schema schema) {
        this.schema = schema;
    }

    @Override
    public void write(ProtostuffOutput output, int index, Object value, boolean repeat) throws IOException {
        output.writeObject(index, value, schema, repeat);
    }

    @Override
    public Object mergeFrom(ByteArrayInput input) throws IOException {
        return input.mergeObject(null, schema);
    }
}
